﻿// Sheego.Service.X400
// Copyright(C) 2015 Schwab Versand GmbH
//
// This source file is subject to the Microsoft Public License(Ms-PL).
// http://www.opensource.org/licenses/ms-pl.html
// All other rights reserved.
using Sheego.Service.X400.Job.Shared;
using Sheego.Service.X400.Job.Shared.BO;
using Sheego.Service.X400.Job.Shared.Locator;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Text;
using System.Threading.Tasks;


namespace Sheego.Service.X400.Job.Impl.BO
{
    class RuleConfigurationAdapter : IJobRuleConfiguration
    {
        private IXmlWrapper RuleFileWrapper;

        public RuleConfigurationAdapter()
        {
            var RuleFile = ConfigurationManager.AppSettings["RuleFilePath"];

           
            RuleFileWrapper = JobLocator.GetXmlWrapper(RuleFile,"ns","http://sheego.de/Sheego.Service.X400/Rules");
            RuleFileWrapper.Update();
        }

        #region IJobRuleConfiguration Members

        public IList<IX400MessageRule> MessageRules
        {
            get
            {
                RuleFileWrapper.Update();
                return RuleFileWrapper.GetElementsByXPath<IX400MessageRule>("/ns:Rules/ns:Rule");
            }
        }

        #endregion
    }
}
